package com.autolinq.util.http;


import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.ByteBuffer;
import java.util.Date;
import java.util.Map;
import java.util.logging.Level;

import net.sf.json.JSONObject;
import sun.misc.BASE64Decoder;

import com.baidu.bae.api.factory.BaeFactory;
import com.baidu.bae.api.fetchurl.BaeFetchurl;

public class HttpPostMessage {
	public static final String GET_URL = "http://api.map.baidu.com/geocoder?output=json&key=ba0f48be137b04cee15730fca5029d71&location=";
	
	public static final String GET_REV_URL = "http://api.map.baidu.com/geocoder/v2/?ak=4253b65134871085f11df3c0989f5634&output=json";
	//public static final String GET_REV_URL = "http://api.map.baidu.com/geocoder?output=json&key=ba0f48be137b04cee15730fca5029d71";

	public static final String POST_URL = "http://www.jiucool.com/request.php";
	
	public static java.util.logging.Logger log = java.util.logging.Logger.getLogger("BdHttpRequest.class");

	public static String readContentFromGet(String location) throws IOException {
		// 拼凑get请求的URL字串，使用URLEncoder.encode对特殊和不可见字符进行编码
		String getURL = GET_URL + location;
		URL getUrl = new URL(getURL);
		// 根据拼凑的URL，打开连接，URL.openConnection函数会根据URL的类型，
		// 返回不同的URLConnection子类的对象，这里URL是一个http，因此实际返回的是HttpURLConnection
		HttpURLConnection connection = (HttpURLConnection) getUrl
				.openConnection();
		// 进行连接，但是实际上get request要在下一句的connection.getInputStream()函数中才会真正发到
		// 服务器
		connection.connect();
		// 取得输入流，并使用Reader读取
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				connection.getInputStream(), "utf-8"));// 设置编码,否则中文乱码
		StringBuffer sb = new StringBuffer();
		String lines;
		while ((lines = reader.readLine()) != null) {
			// lines = new String(lines.getBytes(), "utf-8");
			sb.append(lines);
		}
		reader.close();
		// 断开连接
		connection.disconnect();
		return sb.toString();
	}
	
	public static String readContentFromGet(String url,String location) throws IOException {
		// 拼凑get请求的URL字串，使用URLEncoder.encode对特殊和不可见字符进行编码
		String getURL = url;
		URL getUrl = new URL(getURL);
		// 根据拼凑的URL，打开连接，URL.openConnection函数会根据URL的类型，
		// 返回不同的URLConnection子类的对象，这里URL是一个http，因此实际返回的是HttpURLConnection
		HttpURLConnection connection = (HttpURLConnection) getUrl
				.openConnection();
		// 进行连接，但是实际上get request要在下一句的connection.getInputStream()函数中才会真正发到
		// 服务器
		connection.connect();
		// 取得输入流，并使用Reader读取
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				connection.getInputStream(), "utf-8"));// 设置编码,否则中文乱码
		StringBuffer sb = new StringBuffer();
		String lines;
		while ((lines = reader.readLine()) != null) {
			// lines = new String(lines.getBytes(), "utf-8");
			sb.append(lines);
		}
		reader.close();
		// 断开连接
		connection.disconnect();
		return sb.toString();
	}
	
	public static String readRevContentFromGet(String location) throws IOException {
		// 拼凑get请求的URL字串，使用URLEncoder.encode对特殊和不可见字符进行编码
		String getURL = GET_REV_URL + (location);
		log.log(Level.INFO, "12315"+GET_REV_URL + (location));
		
		BaeFetchurl fetch= BaeFactory.getBaeFetchurl();
		//设置自定义头部
		fetch.setHeader("Expect", "");
		//打开允许重定向开关,默认
		fetch.setAllowRedirect(true);
		//设置最大重定向次数
		fetch.setRedirectNum(2);
		//设置cookie
		fetch.setCookie("timestamp", ""+java.util.Calendar.getInstance().getTimeInMillis());
		//发起一次get请求
		String content = fetch.get(getURL);
		System.out.println(content);
		//获取http code
		int httpcode = fetch.getHttpCode();
		System.out.println(httpcode);
		//获取返回的头部信息
		Map<String, String> header = fetch.getResponseHeader();
		System.out.println(header);
		//获取返回的包体长度
		int len = fetch.getResponseBodyLen();
		System.out.println(len);
		//获取返回的包体数据
		content= fetch.getResponseBody();
		System.out.println(content);
		
		
//		URL getUrl = new URL(getURL);
//		// 根据拼凑的URL，打开连接，URL.openConnection函数会根据URL的类型，
//		// 返回不同的URLConnection子类的对象，这里URL是一个http，因此实际返回的是HttpURLConnection
//		HttpURLConnection connection = (HttpURLConnection) getUrl
//				.openConnection();
//		// 进行连接，但是实际上get request要在下一句的connection.getInputStream()函数中才会真正发到
//		// 服务器
//		connection.connect();
//		// 取得输入流，并使用Reader读取
//		BufferedReader reader = new BufferedReader(new InputStreamReader(
//				connection.getInputStream()));// 设置编码,否则中文乱码
//		StringBuffer sb = new StringBuffer();
//		String lines;
//		while ((lines = reader.readLine()) != null) {
//			// lines = new String(lines.getBytes(), "utf-8");
//			sb.append(lines);
//		}
//		reader.close();
//		// 断开连接
//		connection.disconnect();
//		return sb.toString();
		return content;
	}
	
	public static String getBdRevAddress(String jsonRes){
		log.log(Level.INFO, "12315" + (jsonRes));
		JSONObject jsonObject = null;
		try {
			jsonObject = JSONObject.fromObject(jsonRes);
		} catch (Exception e) {
			e.printStackTrace();
		}
		try{
		if((JSONObject)jsonObject.get("result")!=null){
			return ((JSONObject)((JSONObject)jsonObject.get("result")).get("location")).getString("lng")
			+","+((JSONObject)((JSONObject)jsonObject.get("result")).get("location")).getString("lat");
		}
		}catch(Exception ex){
			return null;
		}
			return null;
	}
	
	public static String getBdAddress(String jsonRes){
		JSONObject jsonObject = null;
		try {
			jsonObject = JSONObject.fromObject(jsonRes);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ((JSONObject)jsonObject.get("result")).getString("formatted_address");
	}
	
	public static byte[] getRemoteImageByte(String strUrl){
		ByteBuffer bb = null;
        try{
		//String strUrl = "http://bcs.duapp.com/mobilesales/upload/1365677077660mrmphoto.jpg";  
		int httpResult = 0; //服务器返回的状态
		
		  URL url = new URL(strUrl); //创建URL
		
		  URLConnection urlconn = url.openConnection(); // 试图连接并取得返回状态码urlconn.connect();
		
		  HttpURLConnection httpconn = (HttpURLConnection) urlconn;
		
		  httpResult = httpconn.getResponseCode();
		
		  System.out.println(httpResult);
		  
		  // 不等于HTTP_OK说明连接不成功
		  if (httpResult != HttpURLConnection.HTTP_OK) {
			  System.out.print("fail");
		  }else {
		      int filesize = urlconn.getContentLength(); 
		      // 取数据长度
		  System.out.println(filesize);
		
		  BufferedInputStream bis=new BufferedInputStream(urlconn.getInputStream());
		  byte[] buffer = new byte[100]; //创建存放输入流的缓冲
		  bb = ByteBuffer.allocate(filesize);
		  int num = -1; //读入的字节数
		
		  while (true) {
			  num = bis.read(buffer,0,100); // 读入到缓冲区
			  System.out.println(num);
			  if(num==-1){
				  break;
			  }
			  
			  bb.put(buffer,0,num);
			  
		  }
		  bis.close();
		  httpconn.disconnect();
		  return bb.array();
          }
        }catch(Exception ex){
        	ex.printStackTrace();
        }
        return null;
	}

	public static String readContentFromPost(String url,String content) throws IOException {
		// Post请求的url，与get不同的是不需要带参数
		URL postUrl = new URL(url);
		// 打开连接
		HttpURLConnection connection = (HttpURLConnection) postUrl
				.openConnection();
		// Output to the connection. Default is
		// false, set to true because post
		// method must write something to the
		// connection
		// 设置是否向connection输出，因为这个是post请求，参数要放在
		// http正文内，因此需要设为true
		connection.setDoOutput(true);
		// Read from the connection. Default is true.
		connection.setDoInput(true);
		// Set the post method. Default is GET
		connection.setRequestMethod("POST");
		// Post cannot use caches
		// Post 请求不能使用缓存
		connection.setUseCaches(false);
		// This method takes effects to
		// every instances of this class.
		// URLConnection.setFollowRedirects是static函数，作用于所有的URLConnection对象。
		// connection.setFollowRedirects(true);

		// This methods only
		// takes effacts to this
		// instance.
		// URLConnection.setInstanceFollowRedirects是成员函数，仅作用于当前函数
		connection.setInstanceFollowRedirects(true);
		// Set the content type to urlencoded,
		// because we will write
		// some URL-encoded content to the
		// connection. Settings above must be set before connect!
		// 配置本次连接的Content-type，配置为application/x-www-form-urlencoded的
		// 意思是正文是urlencoded编码过的form参数，下面我们可以看到我们对正文内容使用URLEncoder.encode
		// 进行编码
		connection.setRequestProperty("Content-Type",
				"application/x-www-form-urlencoded");
		// 连接，从postUrl.openConnection()至此的配置必须要在connect之前完成，
		// 要注意的是connection.getOutputStream会隐含的进行connect。
		connection.connect();
		DataOutputStream out = new DataOutputStream(connection
				.getOutputStream());
		// The URL-encoded contend
		// 正文，正文内容其实跟get的URL中'?'后的参数字符串一致
//		String content = "key=j0r53nmbbd78x7m1pqml06u2&type=1&toemail=jiucool@gmail.com"
//				+ "&activatecode=" + URLEncoder.encode("久酷博客", "utf-8");
		// DataOutputStream.writeBytes将字符串中的16位的unicode字符以8位的字符形式写道流里面
		out.writeBytes(content);
		out.flush();
		out.close(); // flush and close
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				connection.getInputStream(), "utf-8"));// 设置编码,否则中文乱码
		String lineRes = "";
		String line = "";
		System.out.println("=============================");
		System.out.println("Contents of post request");
		System.out.println("=============================");
		while ((line = reader.readLine()) != null) {
			// line = new String(line.getBytes(), "utf-8");
			System.out.println(line);
			lineRes += line;
		}
		System.out.println("=============================");
		System.out.println("Contents of post request ends");
		System.out.println("=============================");
		reader.close();
		connection.disconnect();
		return lineRes;
	}
	
	public static String postXML(String urlStr,String xmlInfo) {  
		String lineResp = "";
        try {  
            URL url = new URL(urlStr);  
            URLConnection con = url.openConnection();  
            con.setDoOutput(true);  
            con.setRequestProperty("Pragma:", "no-cache");  
            con.setRequestProperty("Cache-Control", "no-cache");  
            con.setRequestProperty("Content-Type", "text/xml");  
  
            OutputStreamWriter out = new OutputStreamWriter(con  
                    .getOutputStream());      
            System.out.println("urlStr=" + urlStr);  
            System.out.println("xmlInfo=" + xmlInfo);  
            out.write(new String(xmlInfo.getBytes("utf-8")));  
            out.flush();  
            out.close();  
            BufferedReader br = new BufferedReader(new InputStreamReader(con  
                    .getInputStream()));  
            String line = "";  
            
            for (line = br.readLine(); line != null; line = br.readLine()) {  
                System.out.println(line);  
                lineResp += line;
            }  
        } catch (MalformedURLException e) {  
            e.printStackTrace();  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
        return lineResp;
    }  
	
	public static String postMessage(String urlStr,String xmlInfo) {  
		String lineResp = "";
        try {  
        	System.out.println("urlStr=" + urlStr);  
            URL url = new URL(urlStr);  
            URLConnection con = url.openConnection();  
            con.setDoOutput(true);  
            con.setRequestProperty("Pragma:", "no-cache");  
            con.setRequestProperty("Cache-Control", "no-cache");  
            con.setRequestProperty("Content-Type", "text/xml");  
  
            OutputStreamWriter out = new OutputStreamWriter(con  
                    .getOutputStream());      
            System.out.println("urlStr=" + urlStr);  
            System.out.println("xmlInfo=" + xmlInfo);  
            out.write(new String(xmlInfo.getBytes("utf-8")));  
            out.flush();  
            out.close();  
            BufferedReader br = new BufferedReader(new InputStreamReader(con  
                    .getInputStream(),"utf-8"));  
            String line = "";  
            
            for (line = br.readLine(); line != null; line = br.readLine()) {  
                System.out.println(line);  
                lineResp += line;
            }  
        } catch (MalformedURLException e) {  
            e.printStackTrace();  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
        return lineResp;
    }  
	
	public static String postMessageUTF8(String urlStr,String xmlInfo) {    
		String lineResp = "";
        try {  
            URL url = new URL(urlStr);  
            URLConnection con = url.openConnection();  
            con.setDoOutput(true);  
            con.setRequestProperty("Pragma:", "no-cache");  
            con.setRequestProperty("Cache-Control", "no-cache");  
            con.setRequestProperty("Content-Type", "text/xml");  
  
            OutputStreamWriter out = new OutputStreamWriter(con  
                    .getOutputStream(),"utf-8");      
            System.out.println("urlStr=" + urlStr);  
            System.out.println("xmlInfo=" + xmlInfo);  
            out.write(xmlInfo);  
            out.flush();  
            out.close();  
            BufferedReader br = new BufferedReader(new InputStreamReader(con  
                    .getInputStream(),"utf-8"));  
            String line = "";  
            
            for (line = br.readLine(); line != null; line = br.readLine()) {  
                System.out.println(line);  
                lineResp += line;
            }  
        } catch (MalformedURLException e) {  
            e.printStackTrace();  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
        return lineResp;
    }  
	
	public static String getFromBASE64(String s) {
		if (s == null)
			return null;
		BASE64Decoder decoder = new BASE64Decoder();
		try {
			byte[] b = decoder.decodeBuffer(s);
			return new String(b);
		} catch (Exception e) {
			return null;
		}
	}
	
	public static String testUpdateTrip(){
		
		String json = "{\"Source\":\"WEB\",\"FunctionID\":\"EditTrip\",\"OpenID\":\"o_73AjtyGZZwgBfW2mmlP-lUrS8g\",\"Message\":{\"AppID\":\"System\",\"FuncID\":\"EditTrip\",\"AppVersion\":\"V1.00\",\"TimeStamp\":\"0\",\"Data\":{\"TripID\":\"35\",\"Title\":\"test2\",\"ValidDate\":\"2015-02-28 23:59:59\",\"Destination\":{\"Name\":\"上海虹桥站\",\"City\":\"上海\",\"Loc\":{\"Latitude\":31194237,\"Longitude\":121320876}},\"TripLeader\":\"o_73AjtyGZZwgBfW2mmlP-lUrS8g\"}}}";
		return HttpPostMessage.postXML("http://10.25.2.121:8888/car/rest/webchat/trip/update",json);
	}
	
	public static String retrivePortailts(){
		String json = "";
		   json += "{\"AppID\":\"UserData\",\"FuncID\":\"GetPortraits\",\"AppVersion\":\"V1.00\",\"TimeStamp\":\"200510141940045\",\"SessionID\":5,\"Data\":{\"OpenIDs\":[\"o_73AjtXeKZQRVC_OKHYg9E-bikE\"]}}";   		
		   
		String content = getBASE64(json);
		
		String xmlCon = ""; 
			xmlCon+=" <xml>";
			xmlCon+=" <ToUserName>ToUserName</ToUserName> ";
			xmlCon+=" <FromUserName>ojEq7uNcq817dFKPkWz1xyIUEZkI</FromUserName> ";
			xmlCon+=" <CreateTime>CreateTime</CreateTime> ";
			xmlCon+=" <MsgType>device_type</MsgType> ";
			xmlCon+=" <DeviceType>DeviceType</DeviceType> ";
			xmlCon+=" <DeviceID>1A32267BA0AB11221220</DeviceID> ";
			xmlCon+=" <Content>"+content+"</Content> ";
			xmlCon+=" <SessionID>SessionID</SessionID> ";
			xmlCon+=" <MsgID>MsgID</MsgID> ";
			xmlCon+=" <OpenID>o_73AjkC1vIbFMdSbWha-xSxq5EM</OpenID> ";
			xmlCon+=" </xml> ";
			return HttpPostMessage.postXML("http://localhost:8080/conti/validate",xmlCon);
	}
	
	public static String testGetActiveTripInfo(){
		String json = "";
		   json += "{";
		   		json += "\"AppID\":\"CoDriveTrip\",";
		   		json += "\"FuncID\":\"GetActiveTripInfo\",";
		   		json += "\"AppVersion\":\"V1.00\",";
		   		json += "\"SessionID\":1,";
		   		json += "\"TimeStamp\":\"2014090216322234\",";
		   		json += "\"Data\":";
			   		json += "{";
			   		json += "}";
		   json += "}";   		
		   
		String content = (new sun.misc.BASE64Encoder()).encode(json.getBytes());
		
		String xmlCon = ""; 
			xmlCon+=" <xml>";
			xmlCon+=" <ToUserName>ToUserName</ToUserName> ";
			xmlCon+=" <FromUserName>o_73Ajtc-iwktdfOzjiIfhpra2_o</FromUserName> ";
			xmlCon+=" <CreateTime>CreateTime</CreateTime> ";
			xmlCon+=" <MsgType>device_type</MsgType> ";
			xmlCon+=" <DeviceType>DeviceType</DeviceType> ";
			xmlCon+=" <DeviceID>1A32267BA0AB11221220</DeviceID> ";
			xmlCon+=" <Content>"+content+"</Content> ";
			xmlCon+=" <SessionID>SessionID</SessionID> ";
			xmlCon+=" <MsgID>MsgID</MsgID> ";
			xmlCon+=" <OpenID>o_73AjkC1vIbFMdSbWha-xSxq5EM</OpenID> ";
			xmlCon+=" </xml> ";
			return HttpPostMessage.postXML("http://115.28.109.130/autoLinQ/validate",xmlCon);
	}
	
	public static String testRetrieveDynamicInfo(){
		String json = "";
		   json += "{";
		   		json += "\"AppID\":\"CoDriveTrip\",";
		   		json += "\"FuncID\":\"RetrieveDynamicInfo\",";
		   		json += "\"AppVersion\":\"V1.00\",";
		   		json += "\"SessionID\":1,";
		   		json += "\"TimeStamp\":\"2014090216322234\",";
		   		json += "\"Data\":";
			   		json += "{";
			   		json += "\"DynamicInfo\": {";
			   		json += "\"Loc\": {";
			   		json += "\"Latitude\":31.200120,";
			   		json += "\"Longitude\":121.355583";
			   		json += "},";
			   		json += "\"EstimateTime\": 5,";
			   		json += "\"Distance\": 1000";                   
			   		json += "},";
			   		json += "\"DynamicInfoFields\": {";
			   		json += "\"Loc\":true,";
			   		json += "\"Address\": false,";
			   		json += "\"EstimateTime\": true,";
			   		json += "\"Distance\": true";
			   		json += "}";
			   		json += "}";
		   json += "}";   		
		   
		String content = (new sun.misc.BASE64Encoder()).encode(json.getBytes());
		
		String xmlCon = ""; 
			xmlCon+=" <xml>";
			xmlCon+=" <ToUserName>ToUserName</ToUserName> ";
			xmlCon+=" <FromUserName>o_73Ajtc-iwktdfOzjiIfhpra2_o</FromUserName> ";
			xmlCon+=" <CreateTime>CreateTime</CreateTime> ";
			xmlCon+=" <MsgType>device_type</MsgType> ";
			xmlCon+=" <DeviceType>DeviceType</DeviceType> ";
			xmlCon+=" <DeviceID>1A32267BA0AB11221220</DeviceID> ";
			xmlCon+=" <Content>"+content+"</Content> ";
			xmlCon+=" <SessionID>SessionID</SessionID> ";
			xmlCon+=" <MsgID>MsgID</MsgID> ";
			xmlCon+=" <OpenID>o_73AjkC1vIbFMdSbWha-xSxq5EM</OpenID> ";
			xmlCon+=" </xml> ";
			return HttpPostMessage.postXML("http://115.28.109.130/autoLinQ/validate",xmlCon);
	}
	
	public static String testTerminateCoDriveTrip(){
		String json = "";
		   json += "{";
		   		json += "\"AppID\":\"CoDriveTrip\",";
		   		json += "\"FuncID\":\"TerminateCoDriveTrip\",";
		   		json += "\"AppVersion\":\"V1.00\",";
		   		json += "\"SessionID\":1,";
		   		json += "\"TimeStamp\":\"2014090216322234\",";
		   		json += "\"Data\":";
			   		json += "{";
			   		json += "\"MsgID\": \"1\",";
			   		json += "\"Type\": \"Quit\"";
			   		json += "}";
		   json += "}";   		
		   
		String content = (new sun.misc.BASE64Encoder()).encode(json.getBytes());
		
		String xmlCon = ""; 
			xmlCon+=" <xml>";
			xmlCon+=" <ToUserName>ToUserName</ToUserName> ";
			xmlCon+=" <FromUserName>o_73Ajtc-iwktdfOzjiIfhpra2_o</FromUserName> ";
			xmlCon+=" <CreateTime>CreateTime</CreateTime> ";
			xmlCon+=" <MsgType>device_type</MsgType> ";
			xmlCon+=" <DeviceType>DeviceType</DeviceType> ";
			xmlCon+=" <DeviceID>1A32267BA0AB11221220</DeviceID> ";
			xmlCon+=" <Content>"+content+"</Content> ";
			xmlCon+=" <SessionID>SessionID</SessionID> ";
			xmlCon+=" <MsgID>MsgID</MsgID> ";
			xmlCon+=" <OpenID>o_73AjkC1vIbFMdSbWha-xSxq5EM</OpenID> ";
			xmlCon+=" </xml> ";
			return HttpPostMessage.postXML("http://localhost:8080/auto/validate",xmlCon);
	}
	
	public static String testCoDriveTripAck(){
		String json = "";
		   json += "{";
		   		json += "\"AppID\":\"CoDriveTrip\",";
		   		json += "\"FuncID\":\"CoDriveTripAck\",";
		   		json += "\"AppVersion\":\"V1.00\",";
		   		json += "\"SessionID\":1,";
		   		json += "\"TimeStamp\":\"2014090216322234\",";
		   		json += "\"Data\":";
			   		json += "{";
			   		json += "\"MsgID\": \"1\"";
			   		json += "}";
		   json += "}";   		
		   
		String content = (new sun.misc.BASE64Encoder()).encode(json.getBytes());
		
		String xmlCon = ""; 
			xmlCon+=" <xml>";
			xmlCon+=" <ToUserName>ToUserName</ToUserName> ";
			xmlCon+=" <FromUserName>o_73Ajtc-iwktdfOzjiIfhpra2_o</FromUserName> ";
			xmlCon+=" <CreateTime>CreateTime</CreateTime> ";
			xmlCon+=" <MsgType>device_type</MsgType> ";
			xmlCon+=" <DeviceType>DeviceType</DeviceType> ";
			xmlCon+=" <DeviceID>1A32267BA0AB11221220</DeviceID> ";
			xmlCon+=" <Content>"+content+"</Content> ";
			xmlCon+=" <SessionID>SessionID</SessionID> ";
			xmlCon+=" <MsgID>MsgID</MsgID> ";
			xmlCon+=" <OpenID>o_73AjkC1vIbFMdSbWha-xSxq5EM</OpenID> ";
			xmlCon+=" </xml> ";
			return HttpPostMessage.postXML("http://localhost:8080/auto/validate",xmlCon);
	}
	
	public static String testHeartPulse(){
		String json = "";
		   json += "{";
		   		json += "\"AppID\":\"System\",";
		   		json += "\"FuncID\":\"HeartPulse\",";
		   		json += "\"AppVersion\":\"V1.00\",";
		   		json += "\"SessionID\":1,";
		   		json += "\"TimeStamp\":\"2014090216322234\",";
		   		json += "\"Data\":";
			   		json += "{";
			   		json += "}";
		   json += "}";   		
		   
		String content = (new sun.misc.BASE64Encoder()).encode(json.getBytes());
		
		String xmlCon = ""; 
			xmlCon+=" <xml>";
			xmlCon+=" <ToUserName>gh_f11e546c06f4</ToUserName> ";
			xmlCon+=" <FromUserName>ojEq7uGR9TsrFoGeB1nKqHWazZy4</FromUserName> ";
			xmlCon+=" <CreateTime>1429614074</CreateTime> ";
			xmlCon+=" <MsgType>device_text</MsgType> ";
			xmlCon+=" <DeviceType>DeviceType</DeviceType> ";
			xmlCon+=" <DeviceID>1A32267BA1221809</DeviceID> ";
			xmlCon+=" <Content>"+content+"</Content> ";
			xmlCon+=" <SessionID>SessionID</SessionID> ";
			xmlCon+=" <MsgID>204312226</MsgID> ";
			xmlCon+=" <OpenID>ojEq7uGR9TsrFoGeB1nKqHWazZy4</OpenID> ";
			xmlCon+=" </xml> ";
			return HttpPostMessage.postXML("http://localhost:8080/conti/validate",xmlCon);
	}
	
	public static String testMRMInitBP(){
		String json = "{\"Source\":\"MRN\",\"FunctionID\":\"Init\",\"OpenID\":\"ojEq7uAsF2eyOGKumYh75rLSzg5M\",\"DeviceID\":\"1A32267BA1221810\",\"Message\":{\"AppID\":\"System\",\"FuncID\":\"Init\",\"AppVersion\":\"V1.00\",\"TimeStamp\":\"200510130939321\",\"SessionID\":1,\"Data\":{\"ProductionID\":\"DPCA MRN\",\"QRCodeReq\":true}}}";

		return HttpPostMessage.postXML("http://t.versalinks.com/contiCar/rest/mrn/system/init/",json);
	}
	
	public static String testSubscribeBP(){
		String json = "openId=ojEq7uNfcyhMRFvG6KFDzymZ5bgI";

		return HttpPostMessage.postXML("http://t.versalinks.com/contiCar/rest/passport/subscribe/",json);
	}
	
	public static String testBindBP(){
		String json = "openId=ojEq7uNfcyhMRFvG6KFDzymZ5bgI&deviceId=1A32267BA1221808";

		return HttpPostMessage.postXML("http://t.versalinks.com/contiCar/rest/passport/bind/",json);
	}
	
	public static String testPickupdynamicInfo(){
		String json = "{\"Source\":\"WEB\",\"FunctionID\":\"DynamicInfoPickup\",\"OpenID\":\"o_73Ajt3_ktSSzpILQ9a5_H8m3J8\",\"Message\":{\"AppID\":\"System\",\"FuncID\":\"DynamicInfoPickup\",\"AppVersion\":\"V1.00\",\"TimeStamp\":\"0\",\"Data\":{\"PickupID\":\"13\",\"OpenID\":\"o_73Ajp76VzaNvDy_riVkJWQkpgA\"}}}";
		return HttpPostMessage.postXML("http://localhost:8080/contiCar/rest/pickup/dynamicInfo",json);
	}
	
	public static String testBindBPLocal(){
		String json = "openId=ojEq7uPlhWSDZ0T7oo5WI6zKFj9c&deviceId=1A32267BA0AB11221283";

		return HttpPostMessage.postXML("http://localhost:8080/contiCar/rest/passport/bind/",json);
	}
	
	public static String testUnsubscribeBPLocal(){
		String json = "openId=ojEq7uNcq817dFKPkWz1xyIUEZkI&deviceId=1A32267BA1221809";

		return HttpPostMessage.postXML("http://t.versalinks.com/contiCar/rest/passport/unsubscribe/",json);
	}
	
	public static String testRetrievePickUp(){
		String json = "";
		json +="{";
				json +="\"AppID\": \"CoDrivePickUp\",";
				json +="\"FuncID\": \"RetrievePickUpStatus\",";
				json +="\"AppVersion\": \"V1.00\",";
				json +="\"SessionID\": 1,";
				json +="\"TimeStamp\": \"2014090216322234\",";
				json +="\"Data\": {";
				json +="    \"Loc\": {";
						json +="    \"Latitude\": 29.579916,";
						json +="    \"Longitude\": 115.98905";
						json +="},";
				json +="\"PickUpStatus\": [";
						json +="    {";
						json +="\"MsgID\": \"1\",";
						json +="\"EstimateTime\": 18,";
						json +="\"Distance\": 10";
						json +="}";
				json +="]";
		json +="}";	
		json +="}";	
		   
		String content = (new sun.misc.BASE64Encoder()).encode(json.getBytes());
		
		String xmlCon = ""; 
			xmlCon+=" <xml>";
			xmlCon+=" <ToUserName>ToUserName</ToUserName> ";
			xmlCon+=" <FromUserName>o_73Ajt3_ktSSzpILQ9a5_H8m3J8</FromUserName> ";
			xmlCon+=" <CreateTime>CreateTime</CreateTime> ";
			xmlCon+=" <MsgType>device_type</MsgType> ";
			xmlCon+=" <DeviceType>DeviceType</DeviceType> ";
			xmlCon+=" <DeviceID>1A32267BA0AB11221126</DeviceID> ";
			xmlCon+=" <Content>"+content+"</Content> ";
			xmlCon+=" <SessionID>SessionID</SessionID> ";
			xmlCon+=" <MsgID>MsgID</MsgID> ";
			xmlCon+=" <OpenID>o_73Ajt3_ktSSzpILQ9a5_H8m3J8</OpenID> ";
			xmlCon+=" </xml> ";
			return HttpPostMessage.postXML("http://localhost:8080/auto/validate",xmlCon);
	}
	
	public static String getBASE64(String s) {
		if (s == null)
			return null;
		//return new String(org.apache.commons.codec.binary.Base64.encodeBase64(s.getBytes(),false));
		return new String(org.apache.commons.codec.binary.Base64.encodeBase64(s.getBytes()));
		//return (new sun.misc.BASE64Encoder()).encode(s.getBytes());
	}
	
	public static void main(String[] args){
		try {
			String json = "";
				   json += "{";
				   		json += "\"AppID\":\"System\",";
				   		json += "\"FuncID\":\"Init\",";
				   		json += "\"AppVersion\":\"V1.00\",";
				   		json += "\"SessionID\":1,";
				   		json += "\"TimeStamp\":\"2014090216322234\",";
				   		json += "\"Data\":";
					   		json += "{";
					   		json += "\"ProductionID\":\"DPCA MRN\",";
					   		json += "\"QRCodeReq\":true";
					   		json += "}";
				   json += "}";   		
				   
		   String jsonInitCheck = "";
		   jsonInitCheck += "{";
		   jsonInitCheck += "\"AppID\":\"System\",";
		   jsonInitCheck += "\"FuncID\":\"InitCheck\",";
		   jsonInitCheck += "\"AppVersion\":\"V1.00\",";
		   jsonInitCheck += "\"SessionID\":1,";
		   jsonInitCheck += "\"TimeStamp\":\"2014090216322234\",";
		   jsonInitCheck += "\"Data\":";
		   jsonInitCheck += "{";
	   		jsonInitCheck += "\"Result\":true";
	   		jsonInitCheck += "}";
	   		jsonInitCheck += "}";   	
	   		JSONObject jo = JSONObject.fromObject(json);  
			String content = (new sun.misc.BASE64Encoder()).encode(json.getBytes());
			
			String bss = "{\"AppID\":\"CoDriveTrip\",\"FuncID\":\"TripInfoUpdateNtfy\",\"AppVersion\":\"V1.00\",\"TimeStamp\":\"2014090216322234\",\"Data\":{\"TripID\": \"201407260003\",\"Status\": \"active\",\"Title\":\"2014IC秋游\",\"TripLeader\": \"ogK2FjoNzfXh9URXIuckHClu3Eo4\",\"Date\":{\"Year\":2014,\"Month\":8,\"Day\":14,\"Hour\":15,\"Minute\":20},\"Destination\":{\"Name\": \"庐山\",\"City\": \"庐山\",\"Loc\":{\"Latitude\": 29579916,\"Longitude\":115989050}},\"MemberList\":[\"ogK2FjoNzfXh9URXIuckHClu3Eo4\",\"ogK2FjrYBVTogO0NnyesnFK-guDE\"]}}";
			String content64 = getBASE64(bss);
			String xmlCon = ""; 
					xmlCon+=" <xml>";
					xmlCon+=" <ToUserName>gh_f11e546c06f4</ToUserName> ";
					xmlCon+=" <FromUserName>ojEq7uPlhWSDZ0T7oo5WI6zKFj9c</FromUserName> ";
					xmlCon+=" <CreateTime>1430216064</CreateTime> ";
					xmlCon+=" <MsgType>device_text</MsgType> ";
					xmlCon+=" <DeviceType>DeviceType</DeviceType> ";
					xmlCon+=" <DeviceID>1A32267BA0AB11221283</DeviceID> ";
					xmlCon+=" <Content>"+"eyJBcHBJRCI6IkNvRHJpdmVHTXNnIiwiRnVuY0lEIjoiU2VuZEdyb3VwTXNnIiwiQXBwVmVyc2lvbiI6IlYxLjAwIiwiVGltZVN0YW1wIjoiMjAwNTEwMTQwNDEyMjgyMSIsIlNlc3Npb25JRCI6MjEsIkRhdGEiOnsiTXNnSUQiOiIzMzMiLCJHcm91cFR5cGUiOiJDb0RyaXZlIiwiUmVjdmVySUQiOiIiLCJQa2dJRCI6IjIwMDYwMTAxMTIwOTA1IiwiUGtnSW5kZXgiOjAsIlBrZ051bSI6MSwiVm9pY2VNc2ciOiJNQ2F5ZFk1bXp4R20yUUNxQUdMT2JPWUJBQUFBQUFBQUJRQUFBQUVDb2R5cmpFZXB6eEdPNUFEQURDQlRaV2dBQUFBQUF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QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFnTVFZQWdBQUFBQUFBQUFBQUFBQUFEREVHQUlBQUFBQUFBQUFBUEJyUmdMQXd4Z0NBQUFBQU5FcEJ1UGxKODRSaDEwQVlJeTNnR2J3eEJnQ0FBQ0FBQkRGR0FJQUFBQUFRUUIxQUdRQWFRQnZBQ0FBVWdCbEFHNEFaQUJsQUhJQSJ9fQ=="+"</Content> ";
					xmlCon+=" <SessionID>SessionID</SessionID> ";
					xmlCon+=" <MsgID>204528405</MsgID> ";
					xmlCon+=" <OpenID>ojEq7uPlhWSDZ0T7oo5WI6zKFj9c</OpenID> ";
				xmlCon+=" </xml> ";
				
				String xmlBindCon = ""; 
				xmlBindCon+=" <xml>";
				xmlBindCon+=" <ToUserName>ToUserName</ToUserName> ";
				xmlBindCon+=" <FromUserName>FromUserName</FromUserName> ";
				xmlBindCon+=" <CreateTime>CreateTime</CreateTime> ";
				xmlBindCon+=" <MsgType>device_event</MsgType> ";
				xmlBindCon+=" <Event>bind</Event> ";
				xmlBindCon+=" <DeviceType>DeviceType</DeviceType> ";
				xmlBindCon+=" <DeviceID>1A32267BA0AB11221220</DeviceID> ";
				xmlBindCon+=" <Content>"+content+"</Content> ";
				xmlBindCon+=" <SessionID>SessionID</SessionID> ";
				xmlBindCon+=" <OpenID>o_73AjkC1vIbFMdSbWha-xSxq5EM</OpenID> ";
				xmlBindCon+=" </xml> ";
				
				
				String xml = "<xml>";
				xml += "<ToUserName>Server</ToUserName>";
					xml += "<FromUserName>Client</FromUserName>";
					xml += "<CreateTime>201519130646</CreateTime>";
					xml += "<MsgType>device_type</MsgType>";
					xml += "<DeviceType>DeviceType</DeviceType>";
					xml += "<DeviceID>1A32267BA0AB1122</DeviceID>";
					xml += "<Content>eyJBcHBJRCI6IlN5c3RlbSIsIkZ1bmNJRCI6IkluaXQiLCJBcHBWZXJzaW9uIjoiVjEuMDAiLCJUaW1lU3RhbXAiOiIyMDE1MDEyMTExMjczNDEiLCJEYXRhIjp7IlByb2R1Y3Rpb25JRCI6IkRQQ0EgTVJOIiwiUVJDb2RlUmVxIjp0cnVlfX0=</Content>";
					xml += "</xml>";
			String xmls = getFromBASE64("eyJBcHBJRCI6IkNvRHJpdmVUcmlwIiwiRnVuY0lEIjoiVHJpcEluZm9VcGRhdGVOdGZ5IiwiQXBwVmVyc2lvbiI6IlYxLjAwIiwiVGltZVN0YW1wIjoiMjAxNTAyMTYxMTIyNDkwOSIsIlNlc3Npb25JRCI6MCwiRGF0YSI6eyJTdGF0dXMiOiItMSIsIkFjdGl2ZVRyaXBJRCI6IjQwIiwiRGF0ZSI6eyJZZWFyIjoyMDE1LCJIb3VyIjoyMywiTWludXRlIjo1OSwiRGF5IjoyOCwiTW9udGgiOjJ9LCJUcmlwTGVhZGVyIjoib183M0FqcDc2VnphTnZEeV9yaVZrSldRa3BnQSIsIk1lbWJlclN0YXR1cyI6W3siTmlja25hbWUiOiLlk4jlk4jlk4giLCJTdGF0ZSI6Ik9ubGluZSIsIlNleCI6IkZlbWFsZSIsIk9wZW5JRCI6Im9fNzNBamdvbnFOR1JzUDk2SGZrX2c4a090NDAifSx7Ik5pY2tuYW1lIjoiU25zdGVzdCIsIlN0YXRlIjoiT25saW5lIiwiU2V4IjoiRmVtYWxlIiwiT3BlbklEIjoib183M0FqcDc2VnphTnZEeV9yaVZrSldRa3BnQSJ9XSwiRGVzdGluYXRpb24iOnsiTmFtZSI6IuS4iua1t+a1puS4nOWbvemZheacuuWcuiIsIkxvYyI6eyJMYXRpdHVkZSI6MzExNDk2MzUsIkxvbmdpdHVkZSI6MTIxODAyNTY2fX0sIlRpdGxlIjoidGVzdDQifX0=");
			System.out.println(xmls);
			
			//System.out.println(HttpPostMessage.readContentFromGet("http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=xYPLqTbFGb9tiIcKVzfiyMbU2C32AuTN3AgMiMRlKDc5z83DwJBT0R6kc0scqpm6BqYcITIZ7Vo41ZOg62bI1WTQfxoyfh8bEyxAkbRnVgY&media_id=BQzIPRmhjuofaUk2qxypwQnOSjL3S0b7OhDrG4AVYm2MmtOzpucoTt3WTSYYYeVO", ""));
			;
			//System.out.println(HttpPostMessage.postXML("http://localhost:8080/auto/jsonPortal","{\"Source\": \"WEB\",\"FunctionID\": \"ListVoice\",\"OpenID\": \"o_73Ajtc-iwktdfOzjiIfhpra2_o\",\"Message\": {\"AppID\": \"CoDriveTrip\",\"FuncID\": \"ListVoice\",\"AppVersion\": \"V1.00\",\"SessionID\": 1,\"TimeStamp\": \"2014090216322234\",\"Data\": {\"TripID\": 89,\"OpenID\": \"o_73Ajtc-iwktdfOzjiIfhpra2_o\",\"VoiceType\": 1,\"Cursor\": 0,\"Limit\": 15}}}"));
			System.out.println(HttpPostMessage.postXML("http://codriving.touchmind.com.cn/autoLinQ/validate",xmlCon));
			//System.out.println(getBdRevAddress(HttpPostMessage.readRevContentFromGet("&address="+("张江路185号"))));
			//System.out.println(getBdRevAddress(BdHttpRequest.readContentFromGet("31.21,121,567")));
			//System.out.println(HttpPostMessage.testBindBPLocal());
			
			//HttpPostMessage.postMessage("http://10.25.2.121:8888/car/rest/passport/bind/", "openId=o_73AjtXeKZQRVC_OKHYg9E-bikE&deviceId=1A32267BA0AB11221220");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}